package com.huitian.net.utils;

import java.text.SimpleDateFormat
import java.time.format.DateTimeFormatter
import java.time.{Instant, LocalDateTime, ZoneId, ZonedDateTime}
import java.util.concurrent.TimeUnit
import java.util.{Calendar, Date}

import com.alibaba.fastjson.{JSON, JSONObject}

import scala.collection.mutable.ArrayBuffer

object TimeTest {
  def main(args: Array[String]): Unit = {
    val aa:BigInt=1673183261008650845l
    val str = TimeTest.getTimeHour(aa)
    println(str)







  }
  def getTimeParse(time: BigInt): String = {
    val timeStamp = time.toLong
    val secondsPortion = TimeUnit.NANOSECONDS.toSeconds(timeStamp)
    val nanosPortion  = timeStamp % 1000000000L;
    val instant: Instant = Instant.ofEpochSecond(secondsPortion, nanosPortion);
    val z  = ZoneId.of("Asia/Shanghai");
    val zdt: ZonedDateTime = instant.atZone(z);

    val hour: Int = zdt.getHour
    instant.toString
  }
  def getTimeHour(time: BigInt): String = {
    val timeStamp = time.toLong
    val secondsPortion = TimeUnit.NANOSECONDS.toSeconds(timeStamp)
    val nanosPortion  = timeStamp % 1000000000L;
    val instant: Instant = Instant.ofEpochSecond(secondsPortion, nanosPortion);
    val z  = ZoneId.of("Asia/Shanghai");
    val zdt: ZonedDateTime = instant.atZone(z);

    val hour: Int = zdt.getHour
    hour.toString
  }



}
